package com.budwk.app.sqfwDoc.codeGeneratorV2.excelService;

import com.budwk.app.sqfwDoc.bo.ExcelCreateConfig;
import com.budwk.app.sqfwDoc.codeGeneratorV2.capacity.AbstractCreateExcelCapacity;
import com.budwk.app.sqfwDoc.codeGeneratorV2.capacity.IAfterCreateExcelCapacity;
import com.budwk.app.sqfwDoc.codeGeneratorV2.constants.CodeGeneratorConstants;
import com.budwk.app.sqfwDoc.codeGeneratorV2.fileParam.BaseExcelGPForController;
import com.budwk.app.sqfwDoc.codeGeneratorV2.fileParam.ExcelRowDataParam;
import com.budwk.app.sqfwDoc.codeGeneratorV2.generate.ResultOfExcelGenerator;

import java.util.List;

/**
 * @author ZY.Wang
 * @since 2024/1/25
 */
public abstract class CommonExcelService extends AbstractCreateExcelCapacity implements IAfterCreateExcelCapacity {

    public List<ResultOfExcelGenerator> createExcel(BaseExcelGPForController paramForController) {
        List<ExcelRowDataParam> excelRowDataParamList = getExcelRowDataParamList(paramForController);

        List<ExcelCreateConfig> excelCreateConfigList = paramForController.getExcelCreateConfigList();
        String userId = paramForController.getUserId();
        List<ResultOfExcelGenerator> excelResultList = super.generateExcel(excelCreateConfigList, getDownloadUserParam(userId), excelRowDataParamList, CodeGeneratorConstants.CLIENT_TYPE_APP);
        afterCreateExcel(excelResultList);
        return excelResultList;
    }

    public List<ResultOfExcelGenerator> createExcelForAdmin(BaseExcelGPForController paramForController) {
        List<ExcelRowDataParam> excelRowDataParamList = getExcelRowDataParamListForAdmin(paramForController);

        List<ExcelCreateConfig> excelCreateConfigList = paramForController.getExcelCreateConfigList();
        String userId = paramForController.getUserId();
        return super.generateExcel(excelCreateConfigList, getDownloadUserParam(userId), excelRowDataParamList, CodeGeneratorConstants.CLIENT_TYPE_ADMIN);
    }

    protected abstract List<ExcelRowDataParam> getExcelRowDataParamList(BaseExcelGPForController paramForController);

    protected abstract List<ExcelRowDataParam> getExcelRowDataParamListForAdmin(BaseExcelGPForController paramForController);

}
